const Mock = require('mockjs')
const Random = Mock.Random

let Result = {
  code: 200,
  msg: "操作成功",
  data: null
}

Mock.mock('/captcha' , 'get' , () => {
  Result.data={
    token: Random.string(32),
    captchaImg: Random.dataImage('100x40','p7n5w')
  }

  return Result
})

Mock.mock('/login' , 'post' , () => {
/*  Result.code = 400
  Result.msg = "验证吗错误"*/

  return Result
})

Mock.mock('/sys/userInfo' , 'get' , () => {
  Result.data={
    id: '1',
    username: 'hzj',
    avatar: 'https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=a587b23df11f3a295a9dddcaac159007/500fd9f9d72a60590cfef2f92934349b023bba62.jpg'
  }

  return Result
})

Mock.mock('/logout' , 'post' , () => {
  return Result
})

Mock.mock('/sys/menu/nav' , 'get' , () => {

  /*导航信息*/
  let nav = [
    {
      name: 'SysManga',
      title: '系统管理',
      icon: 'el-icon-s-operation',
      path: '',
      component: '',
      children: [
        {
          name: 'SysUser',
          title: '用户管理',
          icon: 'el-icon-s-custom',
          path: '/sys/user',
          component: '/sys/User',
          children: []
        },
        {
          name: 'SysRole',
          title: '角色管理',
          icon: 'el-icon-rank',
          path: '/sys/role',
          component: '/sys/Role',
          children: []
        },
        {
          name: 'SysMenu',
          title: '菜单管理',
          icon: 'el-icon-menu',
          path: '/sys/menu',
          component: '/sys/Menu',
          children: []
        },
      ]
    },
    {
      name: 'SysTools',
      title: '系统工具',
      icon: 'el-icon-s-tools',
      path: '',
      component: '',
      children: [
        {
          name: 'SysDict',
          title: '数字字典',
          icon: 'el-icon-s-order',
          path: '/sys/dicts',
          component: '/sys/Dicts',
          children: []
        },
      ]
    }
  ]

  /*权限信息*/
  let authoritys = []

  Result.data = {
    nav,
    authoritys
  }

  return Result
})

Mock.mock(RegExp('/sys/role/list*') , 'get' , () => {
  Result.data = {
    'records': [
      {
        name: '普通用户',
        code: 'sys:role:save',
        statu: 1,
        id: 1,
        remark: '上海市普陀区金沙江路 1518 弄'
      },
      {
        name: '超级管理员',
        code: 'sys:role:save',
        statu: 1,
        id: 2,
        remark: '上海市普陀区金沙江路 1518 弄'
      },
    ]
  }
  return Result
})

Mock.mock(RegExp('/sys/role/info*') , 'get' , () => {
  Result.data = {
    'id': 6,
    "created": "2021-01-16T13:29:03",
    "update": "2021-01-17T15:50:45",
    "statu": 1,
    "name": "超级管理员",
    "code": "admin",
    "remark": "系统默认最高权限，不可以编辑和任意修改",
    "menuIds": []
  }
  return Result
})

Mock.mock(RegExp('/sys/role/*') , 'post' , () => {
  return Result
})
